package com.springboot.system.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.springboot.system.domain.auth.Permission;
import com.springboot.common.utils.StringUtils;
import com.springboot.core.jdbc.BaseDao;

/**
 * 权限数据持久层实现类
 * 
 * @ClassName: PermissionDao
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author 252956
 * @date 2021年1月7日 上午9:41:52
 *
 */
@Repository
public class PermissionDao extends BaseDao {

	public List<Permission> selectAll() {
		String sql = "SELECT id,name, parent_id as parentId,types,i_frame,url,levels ,description,sorts,component_name,component_path,icon,cache,hidden,permission_flag as permissionFlag from t_sys_permission order by sorts asc";
		return super.select(sql, Permission.class);
	}

	public List<Permission> selectByRole(Integer[] roleIdList) {
		String sql = "SELECT r.id,r.name, r.parent_id as parentId,r.types,r.i_frame,r.url,r.levels ,r.description,r.sorts,component_name,component_path,icon,cache,hidden,permission_flag as permissionFlag  from t_sys_role_permission rr inner join t_sys_permission r on rr.perm_id=r.id where rr.role_id in ("
				+ StringUtils.join(roleIdList, ",") + ") order by r.sorts asc";
		return super.select(sql, Permission.class);
	}
}
